<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>申请驳回</title>
    <link rel="stylesheet" href="../assets/css/common.css"/>
    <link rel="stylesheet" href="../assets/css/applyReject.css"/>
    <style type="text/css">
        ul, li {
            margin: 0;
            padding: 0;
        }

        li {
            height: 1.5rem;
            line-height: 1.5rem;
            position: relative;
            list-style-type: none;
        }

        .form-section input[type=checkbox] {
            width: auto;
            height: auto;
            top: 0.2rem;
            position: absolute;
        }

        .label-text {
            margin-bottom: 0.4rem;
        }

        .form-section span {
            position: absolute;
            margin-left: 0.5rem;
        }

        .reject-radio {
            width: 10% !important;
            height: 1rem !important;
            margin-bottom: 0 !important;
        }

        .submit-status {
            color: #c69b18;
        }


    </style>
</head>
<body>
<div class="business-section">
    <!-- <div class="business-container">
        <div class="business-info">
                    <div class="business-item-lg business-item-bold">集装箱号：XXXXXXXXXXXX</div>
                    <div class="business-item-lg">业务编号：xxxxxxxxxxxx</div>
                    <div class="business-item-lg">合同协议号：XXXXXXXXXX</div>
                    <div class="business-item-sm">进出口类型：出口</div>
                    <div class="business-item-sm">收发货人：XXXX</div>
                    <div class="business-item-sm">申报报关行：XXXXXXXX</div>
                    <div class="business-item-sm">业务状态：<span class="pay-status">未付款</span></div>
                </div>
                <div class="business-sum">
                    ￥23000
                </div>
    </div>	 -->
    <div class="business-container business-container-template">
        <div class="business-info">
            <div class="business-item-lg business-item-bold business-containerNo">集装箱号:<span></span>
            </div>
            <div class="business-item-lg business-No">业务编号:<span></span></div>
            <div class="business-item-lg business-contractNo">合同协议号:<span></span></div>
            <div class="business-item-sm business-type">进出口类型:<span></span></div>
            <div class="business-item-sm business-owner">收发货人:<span></span></div>
            <div class="business-item-sm business-broker">申报报关行:<span></span></div>
            <div class="business-item-sm business-status">业务状态:<span></span></div>
        </div>
        <div class="business-sum">
            ￥23000
        </div>
    </div>
</div>
<div class="reject-reasons">
    <form action="" class="form-section">
        <div class="label-text">驳回原因:</div>
        <ul>
            <!-- <li><input type="checkbox" value="0"/><span>驳回原因一驳回原因一驳回原因一驳回原因一</span></li>
            <li><input type="checkbox" value="1"/><span>驳回原因二</span></li>
            <li><input type="checkbox" value="2"/><span>驳回原因三</span></li>
            <li><input type="checkbox" value="3"/><span>驳回原因四</span></li>
            <li><input type="checkbox" value="4"/><span>驳回原因五</span></li> -->
        </ul>
        <textarea name="" id="" rows="10">备注
        	</textarea>
        <button type="button" class="common-btn">提交</button>
    </form>
</div>
<script type="text/javascript" src="../assets/js/jquery.js"></script>
<script type="text/javascript" src="../assets/js/config.js"></script>
<script type="text/javascript" src="../assets/js/common.js"></script>
<script type="text/javascript" src="../assets/plugin/layer/layer.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
                   /*url:'../assets/js/testData/applyReject.js',*/
                   url: addressUrl + "exactly_bizInfo_from_id",
                   type: 'get',
                   data: getParams(),
                   dataType: 'json',
                   success: function (data) {
                       var result = data;
                       if (result.error_code == "0") {
                           var $clone = $(".business-container-template").clone()
                                   .removeClass("business-container-template");
                           $clone.find(".business-containerNo span").text(result.container_no).end()
                                   .find(".business-No span").text(result.business_id).end()
                                   .find(".business-contractNo span").text(result.contact_no).end()
                                   .find(".business-type span").text(result.ie_type).end()
                                   .find(".business-owner span").text(result.consigneeOrConsignor).end()
                                   .find(".business-broker span").text(result.supplier).end()
                                   .find(".business-status span").text((result.pay_state_code
                                                                        == "0")
                                                                               ? result.pay_state
                                                                               : result.biz_state);
                           if (result.pay_state_code == "0") {
                               $clone.find(".business-sum").text(result.fee);
                               $clone.find(".business-status").find("span")
                                       .addClass("notPay-status");
                           } else {
                               $clone.find(".business-sum").remove();
                               $clone.find(".business-info").addClass("business-info-unNormal");
                               $clone.find(".business-status").find("span")
                                       .addClass("submit-status");
                           }
                           $(".business-section").append($clone);
                       } else {
                           window.location.href = "brokedown.html";
                       }

                   },
                   error: function (a, b, c) {
                       alert("请求出现错误");
                   }
               });

        var params = getParams().split("&");
        var obj = {};
        for (var i = 0; i < params.length; i++) {
            var paramsArr = params[i].split("=");
            obj[paramsArr[0]] = paramsArr[1];
        }
        $.ajax({
                   /*url: '../assets/js/testData/rejectReason.js',*/
                   url: addressUrl + "gen/reject_reason_list",
                   type: 'get',
                   /*data: {"code": obj.code},*/
                   dataType: 'json',
                   success: function (data) {
                       if (data.error_code == "0") {
                           var result = data.content;
                           for (var i = 0; i < result.length; i++) {
                               $(".form-section ul").append("<li><input class=\"reject-radio\" name=\"reject-radio-option\" type=\"radio\" value='"
                                                            + result[i].id + "'/><span>"
                                                            + result[i].txt + "</span></li>");
                           }
                       } else {
                           window.location.href = "brokedown.html";
                       }
                   }
               });
        var getRejectReasons = function () {
            var reasonArr = [];
            $('input[type=radio]:checked').each(function () {
                var val = $(this).val();
                reasonArr.push(val);
                /*var json = JSON.stringify(reasonArr);
                 console.log(json);*/
            });
            return reasonArr;
        };

        $(".common-btn").on("click", function () {

            $.ajax({
                       /*url: '../assets/js/testData/response.js',*/
                       url: addressUrl + "/apply_for_reject",
                       data: {
                           business_id: getParams().split("=")[1],
                           remark: $("textarea").val(),
                           rejectReasonList: getRejectReasons().join(",")
                       },
                       type: 'get',
                       dataType: 'json',
                       success: function (data) {
                           if (data) {
                               if (!data.result) {
                                   layer.alert(data.msg);
                               } else {
                                   window.location.href = "successReject.html";
                               }
                           } else {
                               window.location.href = "brokedown.html";
                           }
                       },
                       error: function (a, b, c) {
                           alert(b);
                       }
                   });

        });
    });
</script>
</body>
</html>
